package compilador.util;

public enum OperadorRelacional {
	
	MAIOR_QUE(">", new String[] { "cgt" }), 
	MAIOR_IGUAL_A(">=", new String[] { "clt", "ldc.i4.1", "xor" }), 
	MENOR_QUE("<", new String[] { "clt" }), 
	MENOR_IGUAL_A("<=", new String[] { "cgt", "ldc.i4.1", "xor" }), 
	IGUAL_A("==", new String[] { "ceq" }), 
	DIFERENTE_DE("!=", new String[] { "ceq", "ldc.i4.1", "xor" });

	private String[] code;
	private String lexema;

	private OperadorRelacional(String lexema, String[] code) {
		this.lexema = lexema;
		this.code = code;
	}

	public String[] getCodeArray() {
		return this.code;
	}

	public String toString() {
		return this.lexema;
	}

	public static OperadorRelacional fromString(String text) {
		if (text != null) {
			for (OperadorRelacional b : OperadorRelacional.values()) {
				if (text.equalsIgnoreCase(b.lexema)) {
					return b;
				}
			}
		}
		
		return null;
	}
}
